/*
 * @Author: wangjj3
 * @Date: 2022-10-18 11:35:33
 * @Description: signthequote content
 */
import dayjs from 'dayjs';
import DefaultResult from '../../common/DefaultResult';

class SignthequoteResult extends DefaultResult {
  constructor(data, param) {
    super(param);
    this.data = data;
    this.param = param;
  }

  /**
   * 获取人事发文返回值结果
   * @returns 人事发文保存的返回值
   */
  getData = async () => {
    const {
      taskInfo, processInstance, telphone
    } = this.param;
    const {
      draftUser: {
        userName,
        deptName,
      },
    } = processInstance;

    const param = this.data ?? {
      // principal: userName,
      department: deptName,
      createTime: taskInfo.createTime,
      contract: userName,
      secret: '0',
      urgencys: '1',
      serialNumber: `签报﹝${dayjs().format('YYYY')}﹞号`,
      mainSendText: '公司领导',
      contractPhone: telphone,
      ...this.getDefaultResult()
    };
    const {
      // 业务表单自定义数据
      documentInfo,
    } = param;
    const document = JSON.parse(documentInfo);
    return {
      ...param,
      ...document,
    };
  }
}

export default SignthequoteResult;
